import {
    DIC
} from '@/const/dic';
import {
    timeFormatter
} from '../formatter';
import Store from '../../store/';
const userRoleId = Store.state.user.userInfo.roleId;
const isCaptain = userRoleId === 1;
export const inviteCodeTableOption = {
    border: true,
    index: true,
    selection: true,
    calcHeight: 380,
    columnBtn: false,
    height: "auto",
    menu: true,
    searchClearable: false,
    selectClearBtn: false,
    searchResetBtn: false,
    clearable: false,
    tip: false,
    menuAlign: "center",
    searchBtn: true,
    labelWidth: 150,
    refreshBtn: true,
    addBtn: true,
    dialogWidth: '600px',
    dialogHeight: 'auto',
    menuWidth: 180,
    editBtn: true,
    viewBtn: false,
    delBtn: true,
    column: [{
            "label": "邀请码",
            "prop": "Code",
            "search": true,
            "type": "text",
            "fixed": false,
            "width": 120,
            "row": true,
            "readonly": false,
            "span": 20,
            "display": false,
            "rules": [{
                "required": true,
                "message": "请输入邀请码",
                "trigger": "blur"
            }]
        },
        {
            "label": "创建时间",
            "prop": "CreateTime",
            "search": false,
            formatter: timeFormatter,
            "type": "datetime",
            "fixed": false,
            "width": "160",
            "minWidth": "120",
            "readonly": false,
            "span": 12,
            "display": false
        },
        {
            "label": "有效期（小时）",
            "prop": "ValidHours",
            "search": false,
            "type": "number",
            "fixed": false,
            "width": 120,
            "row": true,
            "minWidth": "120",
            "readonly": false,
            "span": 16,
            "display": true,
            "rules": [{
                "required": true,
                "message": "请输入有效期（小时）",
                "trigger": "change"
            }, {
                min: 1,
                "message": "有效期（小时）不能小于1",
                "trigger": "change",
                type: 'number'
            }]
        },

        {
            "label": "状态",
            "prop": "Status",
            "search": true,
            "type": "select",
            slot: true,
            "fixed": false,
            "width": "auto",
            "minWidth": "120",
            "readonly": false,
            "span": 12,
            "display": false,
            "placeholder": "请选择状态",
            "dicData": DIC['inviteCodeStatus']
        },
        {
            "label": "团长",
            "prop": "CaptainId",
            "search": false,
            "type": "select",
            props: {
                label: 'label',
                value: 'value'
            },
            dicUrl: !isCaptain ? '/admin/all-captain' : '',
            "fixed": false,
            filterable: true,
            "width": 120,
            "row": true,
            "minWidth": "120",
            "readonly": false,
            "span": 16,
            "hide": isCaptain,
            "display": !isCaptain,
            "rules": [{
                "required": true,
                "message": "请选择团长",
                "trigger": "change"
            }]
        }
    ]
};
